package com.woniu.immunologicalmechanism.mapper;

import com.woniu.common.entity.Organization;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface OrganizationMapper {
    //添加免疫机构
    @Insert("insert into organization values(null,#{oname},#{tel},#{address},#{scope_of_service},#{work_time})")
    void insertorganization(Organization organization);
    //修改免疫机构信息
    @Update("update organization set oname=#{oname},tel=#{tel},address=#{address},scope_of_service=#{scope_of_service},work_time=#{work_time} where id=#{id}")
    void updateorganization(Organization organization);
    //删除免疫机构
    @Update("update organization set status=0 where id=#{id}")
    void deleteorganization(int oid);
    //根据id查询免疫机构信息
    @Select("select * from organization where id=#{id}")
    Organization selectOrganization(int oid);
    //根据名字模糊查询所有免疫机构信息
    @Select("select * from organization where oname LIKE CONCAT('%', #{oname}, '%')")
    List<Organization> selectOrganizationByname(String oname);
    //根据员工id查询对应机构id
    @Select("select oid from user_organization where uid=#{uid}")
    int selectOrganizationId(int uid);

}
